// src/utils/security.rs - 安全工具

use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// 认证类型
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AuthType {
    None,
    Basic,
    Bearer,
    ApiKey,
    OAuth2,
    Certificate,
}

/// 安全配置
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SecurityConfig {
    pub auth_type: AuthType,
    pub credentials: Option<HashMap<String, String>>,
    pub certificates: Option<CertificateConfig>,
    pub encryption: Option<EncryptionConfig>,
}

/// 证书配置
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CertificateConfig {
    pub cert_file: Option<String>,
    pub key_file: Option<String>,
    pub ca_file: Option<String>,
    pub cert_data: Option<String>,
    pub key_data: Option<String>,
}

/// 加密配置
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EncryptionConfig {
    pub algorithm: String,
    pub key_length: u32,
    pub iv_length: u32,
}

impl Default for SecurityConfig {
    fn default() -> Self {
        Self {
            auth_type: AuthType::None,
            credentials: None,
            certificates: None,
            encryption: None,
        }
    }
}